package org.com.structuralPattern.compositePattern;

/**
 * @author Jonny
 * @version 1.0
 * @Description:
 * @date 2021/4/15 11:05
 */
public class Client {
    public static void main(String[] args) {
        Composite root=new Composite();
        root.operation();
        Composite branch=new Composite();
        Leaf leaf=new Leaf();
        root.add(branch);
        branch.add(leaf);
    }

    public static void display(Composite root){
        for (Component c:root.getChild()){
            if(c instanceof Leaf){
                c.operation();
            }else {
                display((Composite) c);
            }
        }
    }
}
